﻿Module Module1
    Function Bai18(ByVal x As Double, ByVal n As Integer) As Double
        Dim S As Double = 1
        Dim M As Integer = 1
        Dim T As Double = x
        Dim i As Integer
        For i = 2 To 2 * n Step 2
            T = x ^ i
            M = M * (i - 1) * i
            S = S + T / M
        Next
        Return S
    End Function
    Sub Main()
        Dim x As Integer
        Console.WriteLine("Nhap so x: ")
        x = Console.ReadLine()
        Dim n As Integer
        Console.WriteLine("Nhap so n: ")
        n = Console.ReadLine()
        Dim kq As Double
        kq = Bai18(x, n)
        Console.WriteLine("S(n)= " & kq)
    End Sub
End Module
